package com.fr.chicken.controller;

import com.fr.chicken.annotation.Verification;
import com.fr.chicken.facade.base.BaseResponseDTO;
import com.fr.chicken.facade.request.GetUserExchangeListRequsetDTO;
import com.fr.chicken.facade.request.UserExchangeRequsetDTO;
import com.fr.chicken.facade.response.GetExchangeConfigureResponseDTO;
import com.fr.chicken.facade.response.GetUserExchangeListResponseDTO;
import com.fr.chicken.service.ExchangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/exchange")
@Api(value = "/api-exchange", description = "兑换管理")
public class ExchangeController {

    @Autowired
    private ExchangeService exchangeService;

    @Verification
    @ApiOperation(value = "兑换配置信息", notes = "兑换配置信息")
    @RequestMapping(value = "/getExchangeConfigure", method = RequestMethod.GET, produces = "application/json")
    public GetExchangeConfigureResponseDTO getExchangeConfigure(@RequestHeader String accessToken) {
        GetExchangeConfigureResponseDTO response = exchangeService.getExchangeConfigure();
        return response;
    }

    @Verification
    @ApiOperation(value = "兑换物品", notes = "兑换物品")
    @RequestMapping(value = "/userExchange", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO userExchange(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) UserExchangeRequsetDTO requset) {
        BaseResponseDTO response = exchangeService.userExchange(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "获取用户兑换列表", notes = "获取用户兑换列表")
    @RequestMapping(value = "/getUserExchangeList", method = RequestMethod.GET, produces = "application/json")
    public GetUserExchangeListResponseDTO getUserExchangeList(@RequestHeader String accessToken,GetUserExchangeListRequsetDTO requset) {
        GetUserExchangeListResponseDTO response = exchangeService.getUserExchangeList(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "设置已发货", notes = "设置已发货")
    @RequestMapping(value = "/setStatus/{id}", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO setStatus(@RequestHeader String accessToken,@PathVariable(value = "id") @ApiParam(required = true, value = "兑换记录id") Integer id) {
        BaseResponseDTO response = exchangeService.setStatus(id);
        return response;
    }
}
